home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJSRC111.ZIP / go32 / xms.h < prev   
C/C++ Source or Header  |  1993-06-20  |  6KB  |  208 lines

  1. /*
  2. ** xms.h -- C bindings for xms API
  3. ** Author: Kent Williams william@umaxc.weeg.uiowa.edu
  4. **
  5. ** This is an attempt to provide a complete C binding
  6. ** for the XMS calls.
  7. **
  8. ** All calls will store the error code in xms_error.  I have
  9. ** tried to document how the calls work in this file where their
  10. ** prototypes are given.
  11. */
  12. #ifndef __XMS_H
  13. #define __XMS_H
  14.  
  15. /*
  16. ** extended memory block types
  17. */
  18. typedef unsigned short emb_size_K_t;
  19. typedef unsigned long  emb_off_t;
  20. typedef short emb_handle_t;
  21.  
  22. /*
  23. ** upper memory block types.
  24. */
  25. typedef unsigned short umb_segment_t;
  26. typedef unsigned short umb_size_t;
  27.  
  28. /*
  29. ** structure defining information returned
  30. ** from xms_query_extended_memory
  31. */
  32. typedef struct _xms_extended_info {
  33.     emb_size_K_t max_free_block;
  34.     emb_size_K_t total_extended_memory;
  35. } xms_extended_info;
  36.  
  37. /*
  38. ** structure defining information returned
  39. ** from xms_get_version_info
  40. */
  41. typedef struct _xms_version_info {
  42.     unsigned xms_ver;
  43.     unsigned xmm_ver;
  44.     unsigned hma_present;
  45. } xms_version_info;
  46.  
  47. /*
  48. ** structure defining information returned from
  49. ** xms_get_emb_handle_info
  50. */
  51. typedef struct _emb_handle_info {
  52.     unsigned char lock_count;
  53.     unsigned char handles_available;
  54.     emb_size_K_t block_size;
  55. } emb_handle_info;
  56.  
  57. /*
  58. ** move parameter block for extended memory moves.
  59. */
  60. typedef struct _xms_move_param {
  61.     emb_off_t length;
  62.     emb_handle_t source_handle;
  63.     emb_off_t source_offset;
  64.     emb_handle_t dest_handle;
  65.     emb_off_t dest_offset;
  66. } xms_move_param;
  67.  
  68. /*
  69. ** upper memory block info blockblock
  70. */
  71. typedef struct _umb_info {
  72.     umb_segment_t segment;
  73.     umb_size_t block_size;
  74. } umb_info;
  75.  
  76. extern char xms_error;
  77. /*
  78. ** xms error codes
  79. */
  80. #define XMS_NOT_IMPLEMENTED        0x80
  81. #define XMS_VDISK_DETECTED        0x81
  82. #define XMS_A20_ERROR            0x82
  83. #define XMS_DRIVER_ERROR        0x8e
  84. #define XMS_FATAL_DRIVER_ERROR    0x8f
  85. #define XMS_NO_HMA                0x90
  86. #define XMS_HMA_INUSE            0x91
  87. #define XMS_HMA_DX_TOO_SMALL    0x92
  88. #define XMS_HMA_NOT_ALLOCATED    0x93
  89. #define XMS_A20_STILL_ENABLED    0x94
  90. #define XMS_EXT_NO_MEM            0xa0
  91. #define XMS_EXT_NO_HANDLES        0xa1
  92. #define XMS_EXT_BAD_HANDLE        0xa2
  93. #define XMS_EXT_BAD_SRC_HANDLE    0xa3
  94. #define XMS_EXT_BAD_SRC_OFFSET    0xa4
  95. #define XMS_EXT_BAD_DST_HANDLE    0xa5
  96. #define XMS_EXT_BAD_DST_OFFSET    0xa6
  97. #define XMS_EXT_BAD_LENGTH        0xa7
  98. #define XMS_EXT_OVERLAP            0xa8
  99. #define XMS_EXT_PARITY            0xa9
  100. #define XMS_EXT_NOT_LOCKED        0xaa
  101. #define XMS_EXT_LOCKED            0xab
  102. #define XMS_EXT_NO_LOCKS        0xac
  103. #define XMS_EXT_LOCK_FAILED        0xad
  104. #define XMS_UMB_SMALLER_AVAIL    0xb0
  105. #define XMS_UMB_NO_MEM            0xb1
  106. #define XMS_UMB_BAD_SEG            0xb2
  107.  
  108. int xms_installed(void);
  109.  
  110. /* xms function 00H 
  111. ** returns pointer to static info block
  112. */
  113. xms_version_info * xms_get_version_info(void);
  114.  
  115. /* xms function 01H
  116. ** returns 0 on success, non-zero on failure
  117. ** if it succeeds, the address of the hma is 0xffff:0010H
  118. ** the size parameter is screwy; it is documented to be 0xffff for an
  119. ** application,or the actual size needed for a driver.
  120. */
  121. int xms_hma_allocate(unsigned size);
  122.  
  123. /* xms function 02H
  124. ** returns 0 on success, non-zero on failure
  125. */
  126. int xms_hma_free(void);
  127.  
  128. /*
  129. ** The following functions diddle the A20 address line.  A20 has to
  130. ** be enabled in order to address memory > 1Mbyte, i.e. the HMA
  131. ** You are supposed to use the global functions if you are 'the owner'
  132. ** of the HMA, the local functions if you are not. You own the HMA
  133. ** if your call to xms_hma_allocate succeeded.
  134. ** The distinction between global and local aren't really explained
  135. ** in the stuff I have;  my inclination would be to try to get the hma
  136. ** with xms_hma_allocate and then just use the global functions.
  137. */
  138. /* xms function 03H */
  139. int xms_global_enable_a20(void);
  140. /* xms function 04H */
  141. int xms_global_disable_a20(void);
  142. /* xms function 05H */
  143. int xms_local_enable_a20(void);
  144. /* xms function 06H */
  145. int xms_local_disable_a20(void);
  146.  
  147. /* xms function 07H
  148. ** returns 1 if the line is enabled, 0 if it isn't.
  149. ** actually (!xms_a20_status && !xms_error) would indicate disabled
  150. ** status; if the error is non-zero, then the call failed for some screwy
  151. ** reason
  152. */
  153. int xms_a20_status(void);
  154.  
  155. /* xms function 08H
  156. ** this call returns a pointer to a static info area
  157. */
  158. xms_extended_info *xms_query_extended_memory(void);
  159.  
  160. /* xms function 09H
  161. ** returns an emb handle, or -1 if allocation fails
  162. */
  163. int xms_emb_allocate(emb_size_K_t size);
  164.  
  165. /* xms function 0AH
  166. ** returns 0 on success non-zero on failure
  167. */
  168. int xms_emb_free(emb_handle_t handle);
  169.  
  170. /* xms function 0BH
  171. ** returns 0 on success non-zero on failure
  172. */
  173. int xms_move_emb(xms_move_param *x);
  174.  
  175. /* xms function 0CH
  176. ** returns 32 bit linear address of emb specified by handle,
  177. ** 0 otherwise.
  178. */
  179. emb_off_t xms_lock_emb(emb_handle_t handle);
  180.  
  181. /* xms function 0DH
  182. ** returns 0 on success non-zero on failure
  183. */
  184. int xms_unlock_emb(emb_handle_t handle);
  185.  
  186. /* xms function 0EH
  187. ** returns poitner to static information buffer, or null on failure
  188. */
  189. emb_handle_info *xms_get_emb_handle_info(emb_handle_t handle);
  190.  
  191. /* xms function 0FH
  192. ** returns 0 on success, non-zero on failure
  193. */
  194. int xms_emb_resize(emb_handle_t handle,emb_size_K_t size);
  195.  
  196. /* xms function 10H 
  197. ** returns pointer to static umb info block, or NULL
  198. ** if call fails
  199. */
  200. umb_info * xms_umb_allocate(umb_size_t size);
  201.  
  202. /* xms function 11H 
  203. ** returns 0 on success, non-zero on failure
  204. */
  205. int xms_umb_free(umb_segment_t segment);
  206.  
  207. #endif /* XMS_H */
  208.